package com.heima.wemedia.controller.v1;

/**
 * author Link
 *
 * @version 1.0
 * @date 2025/4/16  13:31
 */

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmSensitivePageDto;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.service.WmSensitiveService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController()
@RequestMapping("/api/v1/sensitive")
@Slf4j
public class WmSensitiveController {

    @Autowired
    private WmSensitiveService wmSensitiveService;


    /**
     * 新增敏感词
     * @return
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmSensitive dto){
        log.info("新增敏感词");
       return wmSensitiveService.addSensitive(dto);
    }

    /**
     * 查询敏感词列表
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmSensitivePageDto dto){
        log.info("查询敏感词列表:{}",dto);
        return wmSensitiveService.listSensitive(dto);
    }

    /**
     * 修改敏感词
     * @param wmSensitive
     * @return
     */
    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmSensitive wmSensitive){
        log.info("修改敏感词：{}",wmSensitive);
        return wmSensitiveService.updateSensitive(wmSensitive);
    }

    /**
     * 删除敏感词
     * @param id
     * @return
     */
    @DeleteMapping("/del/{id}")
    public ResponseResult delete(@PathVariable Integer id){
        log.info("删除敏感词：{}",id);
        return wmSensitiveService.deleteSensitive(id);
    }
}
